import request from '@/utils/request'
import { uploadFile } from '@/utils/request'

export function uploadDocs({formData={},fileList,url="rest/doc/uploadDoc",filePath, timeout}) {
	let files = []
	for (let item of fileList) {
		let obj = {
			name: "attach",
			uri: item.url
		}
		files.push(obj)
	}
	return uploadFile({url, formData, files, filePath, timeout})
}

export function uploadWatermarkDocs({formData={},fileList,url="composite/picture/addPictureText",filePath, timeout, name="file"}) {
	let files = []
	for (let item of fileList) {
		let obj = {
			name: "file",
			uri: item.url
		}
		files.push(obj)
	}
	return uploadFile({url, formData, files, filePath, timeout, name})
}

// 根据docId获取图片
export function getPicture(param) {
	return request({
		url: 'rest/doc/attachList',
		method: 'post',
		data: param
	})
}
export function uploadImg(param) {
	return request({
		url: 'rest/doc/uploadImg',
		method: 'post',
		data: param
	})
}
export function deleteImg(param) {
	return request({
		url: 'rest/doc/deleteAttach',
		method: 'post',
		data: param
	})
}

export function doc_deleteAttachs(param) {
	return request({
		url: 'rest/doc/deleteAttachs',
		method: 'post',
		data: param
	})
}
